package cn.lijiajia3515.cairo.auth.modules;

import cn.lijiajia3515.cairo.auth.CairoAuthentication;
import cn.lijiajia3515.cairo.core.business.DefaultBusiness;
import cn.lijiajia3515.cairo.core.exception.BusinessException;
import cn.lijiajia3515.cairo.domain.CairoAccount;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 断路器
 */
@Component
public class AuthenticationClientFallbackFactory implements FallbackFactory<AuthenticationClient> {

	@Override
	public AuthenticationClient create(Throwable cause) {
		return new AuthenticationClient() {
			@Override
			public CairoAuthentication authentication(String authorization) {
				throw new BusinessException("调用失败", cause, DefaultBusiness.Failed);
			}

			@Override
			public CairoAccount account(String authorization) {
				throw new BusinessException("调用失败", cause, DefaultBusiness.Failed);
			}
		};
	}
}
